package com.itheima.day11.bytestream.test10;

import java.io.*;
import java.util.ArrayList;

public class Test {
    public static void main(String[] args) {
        // 创建字节缓冲输入流
        BufferedInputStream bis = null;
        // 创建字节缓冲输出流
        BufferedOutputStream bos = null;
        try {
            bis = new BufferedInputStream(new FileInputStream("myCode\\src\\\\com\\itheima\\day11\\a.txt"));
            bos = new BufferedOutputStream(new FileOutputStream("myCode\\src\\\\com\\itheima\\day11\\b.txt"));
            byte[] chars = new byte[1024];
            int len;
            while((len = bis.read(chars)) != -1){
                bos.write(chars,0,len);
            }
            System.out.println("传输完毕");
        } catch (FileNotFoundException e) {
            System.out.println("找不到文件");
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally{
            if(bis != null){
                try{
                    System.out.println("bis释放资源");
                    bis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if(bos != null){
                try {
                    System.out.println("bos释放资源");
                    bos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
